//-----------------------------------------------------------------------------------
#ifndef _AISTAR_H_
#define _AISTAR_H_
//-----------------------------------------------------------------------------------
#include "StarNode.h"
//-----------------------------------------------------------------------------------
#define MAX_COL 30
#define MAX_ROW 30
//-----------------------------------------------------------------------------------
class AIStar
{
public:

	AIStar();
	AIStar( int iMapa[][MAX_COL], int iMapaWidth, int iMapaHeight );
	~AIStar();

	void InitializeASTar( int iMapa[][MAX_COL], int iMapaWidth, int iMapaHeight );
	
	sPosition ** FindPath( int iColStart,
						   int iRowStart,
						   int iColExit,
						   int iRowExit );
					
	void OpenAdyacents( StarNode * pStarNode );

	int GetManhattan( StarNode * pStarNodeStart, StarNode * pStarNodeExit );

	StarNode * GetLowerStarNode();

	bool IsOpen( StarNode * pkStarNode );
	bool IsClosed( StarNode * pkStarNode );

	void TryToOpen(StarNode * pkParentStarNode, StarNode * pkStarNode );

	void RemoveStarNode(StarNode * pkStarNode);

	void ClearAStar();
	
	StarNode * m_pkStarNode;
	std::vector<std::vector<StarNode*>> m_vAllStarNodes;

	std::vector<StarNode*> m_vOpenStarNodes;
	std::vector<StarNode*> m_vClosedStarNodes;

	int m_iMapaWidth;
	int m_iMapaHeight;

	int m_iStartCol;
	int m_iStartRow;
	int m_iExitCol;
	int m_iExitRow;

	friend class StarNode;
};
//-----------------------------------------------------------------------------------
#endif
//-----------------------------------------------------------------------------------